package com.ruoyi.pims.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.pims.mapper.PurchaseOrderItemMapper;
import com.ruoyi.pims.domain.PurchaseOrderItem;
import com.ruoyi.pims.service.IPurchaseOrderItemService;
import com.ruoyi.common.core.text.Convert;

/**
 * 采购订单明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-17
 */
@Service
public class PurchaseOrderItemServiceImpl implements IPurchaseOrderItemService 
{
    @Autowired
    private PurchaseOrderItemMapper purchaseOrderItemMapper;

    /**
     * 查询采购订单明细
     * 
     * @param itemId 采购订单明细主键
     * @return 采购订单明细
     */
    @Override
    public PurchaseOrderItem selectPurchaseOrderItemByItemId(Long itemId)
    {
        return purchaseOrderItemMapper.selectPurchaseOrderItemByItemId(itemId);
    }

    /**
     * 查询采购订单明细列表
     * 
     * @param purchaseOrderItem 采购订单明细
     * @return 采购订单明细
     */
    @Override
    public List<PurchaseOrderItem> selectPurchaseOrderItemList(PurchaseOrderItem purchaseOrderItem)
    {
        return purchaseOrderItemMapper.selectPurchaseOrderItemList(purchaseOrderItem);
    }

    /**
     * 新增采购订单明细
     * 
     * @param purchaseOrderItem 采购订单明细
     * @return 结果
     */
    @Override
    public int insertPurchaseOrderItem(PurchaseOrderItem purchaseOrderItem)
    {
        purchaseOrderItem.setCreateTime(DateUtils.getNowDate());
        return purchaseOrderItemMapper.insertPurchaseOrderItem(purchaseOrderItem);
    }

    /**
     * 修改采购订单明细
     * 
     * @param purchaseOrderItem 采购订单明细
     * @return 结果
     */
    @Override
    public int updatePurchaseOrderItem(PurchaseOrderItem purchaseOrderItem)
    {
        purchaseOrderItem.setUpdateTime(DateUtils.getNowDate());
        return purchaseOrderItemMapper.updatePurchaseOrderItem(purchaseOrderItem);
    }

    /**
     * 批量删除采购订单明细
     * 
     * @param itemIds 需要删除的采购订单明细主键
     * @return 结果
     */
    @Override
    public int deletePurchaseOrderItemByItemIds(String itemIds)
    {
        return purchaseOrderItemMapper.deletePurchaseOrderItemByItemIds(Convert.toStrArray(itemIds));
    }

    /**
     * 删除采购订单明细信息
     * 
     * @param itemId 采购订单明细主键
     * @return 结果
     */
    @Override
    public int deletePurchaseOrderItemByItemId(Long itemId)
    {
        return purchaseOrderItemMapper.deletePurchaseOrderItemByItemId(itemId);
    }
}
